Date.formats = {
    def: 'dd/MM/yyyy hh:mm:ss',
    dateOnly: 'dd/MM/yy'
}

/**
 *  Converts date to format
 */
Date.prototype.format = function(format) {
    if(!format) format = Date.formats.def; 
    var dd = this.getDate();
    var MM = this.getMonth();
    MM++;
    
    if(dd<10) dd = '0'+dd;
    if(MM<10) MM = '0'+MM;
    
    var yyyy = this.getFullYear();
    var yy = (yyyy+'').substr(2,2);

    var hh = this.getHours();
    var mm = this.getMinutes();
    var ss = this.getSeconds();
    
    if(hh<10) hh = '0'+hh;
    if(mm<10) mm = '0'+mm;
    if(ss<10) ss = '0'+ss;
    
    return format
        .replace('dd', dd)
        .replace('MM', MM)
        .replace('yyyy', yyyy)
        .replace('yy', yy)
        .replace('hh', hh)
        .replace('mm', mm)
        .replace('ss', ss);
}
